<template>
	<z-paging ref="paging" v-model="list" @query="getList" loading-more-default-text="我也是有底线的哦">
		<navBar title="我的消息" />
		<view class="container">
			<view class="list">
				<!-- <navigator url="/pages/user/vip/certificate"> -->
				<view class="col" v-for="item,index in list" :key="item.id" @click="readMessage(item)">
					<view class="left">
						<image src="@/static/user/message2.png" mode="" v-if="item.status == 1"></image>
						<image src="@/static/user/message1.png" mode="" v-if="item.status == 0"></image>
						{{item.content}}
					</view>
					<image src="@/static/arrow-right.png" class="more" mode=""></image>
				</view>
				<!-- 	</navigator>-->
			</view>
		</view>
	</z-paging>
</template>

<script>
	import navBar from "@/pages/user/components/navBar.vue"

	export default {
		components: {
			navBar
		},
		data() {
			return {
				list: [],
				pageNo:1,
				pageSize:20
			}
		},
		onLoad() {},
		methods: {
			getList() {
				this.$get("/user/messageList", {
					pageNum: this.pageNo,
					pageSize: this.pageSize
				}).then(res => {
					//请勿在网络请求回调中给dataList赋值！！只需要调用complete就可以了
					this.$refs.paging.complete(res.data.rows);
				})
			},
			readMessage(item) {
				if(item.status == 1) return false
				this.$post("/user/messageRead", {
					id:item.id
				}).then(res => {
					if(res.code == 200)
					{
						item.status = 1
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.list {
		.col {
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 28rpx;
			padding: 20rpx 0;

			.left {
				display: flex;
				align-items: center;

				image {
					width: 40rpx;
					height: 40rpx;
					margin-right: 10rpx;
				}
			}

			.more {
				width: 36rpx;
				height: 36rpx;
			}
		}
	}
</style>